<?php
Yii::import('application.components.dao.class.Dao');

class AuctionLiveDao extends Dao
{

    public function attributeLabels()
    {
        return array(
            'title' => 'Auction Title',
            'winner_price' => 'Initial Auction Price',
            'winner_price_increment' => 'Bidding Increment'
        );
    }

    public function dataSource()
    {
        return array(
            'AuctionInfo' => array(
                'attributes' => array(
                    'id',
                    'title',
                    'tag',
                    'short_description',
                    'description',
                    'created',
                    'winner_price_increment',
                    'start_time',
                    //'end_time'
                )
            ),
            'AuctionPool' => array(
                'attributes' => array(
                    'status',
                    'start_time',
					'winner_price',
                    'end_time',
                    'winner_id'
                )
            ),
            'AuctionCategoryRelations' => array(
                'attributes' => array(
                    'category_id'
                )
            ),
            'AuctionResourceDao' => array(
                'class' => 'dao.auction.AuctionResourceDao',
                'attributes' => array(
                    'images'
                )
            ),
            'Customer' => array(
                'attributes' => array(
                    'user_name'
                )
            ),
            'CustomerInfo' => array(
                'attributes' => array(
                    'avatar'
                )
            ),
            'AuctionFee'=>array(
                'attributes'=>array(
                    'value_price'
                )
            )
        );
    }

    public function dataSourceRelations()
    {
        return array(
            'AuctionInfo' => array(
                'AuctionPool' => array(
                    'part',
                    'join' => array(
                        'id' => 'auction_id'
                    )
                ),
                'AuctionCategoryRelations' => array(
                    'part',
                    'join' => array(
                        'id' => 'auction_id'
                    )
                ),
                'AuctionResourceDao' => array(
                    'part',
                    'join' => array(
                        'id' => 'auction_id'
                    )
                ),
                'Customer' => array(
                    'part',
                    'join' => array(
                        'winner_id' => 'id'
                    )
                ),
                'CustomerInfo' => array(
                    'part',
                    'join' => array(
                        'winner_id' => 'customer_id'
                    )
                ),
                'AuctionFee'=>array(
                    'part',
                    'join'=>array(
                        'id'=>'auction_id'
                    )
                )
            )
        );
    }
}